<extend name="Public:base"/>

<!--侧边导航-->
<block name="aside">
    <include file="Public:aside"/>
</block>

<block name="main">
<div id="yzh-content" class="col-xs-12">
    <form id="myform" class="form-horizontal" action="{:U('User/add')}" method="post">
        <input type="hidden" name="status" value="1" />
        <div class="form-group">
            <label class="col-sm-2 control-label">用户名</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" name="username">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">密码</label>
            <div class="col-xs-4">
                <input type="password" name="password" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">确认密码</label>
            <div class="col-xs-4">
                <input type="password" name="repassword" class="form-control"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">邮箱</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" name="email" >
            </div>
        </div>

        <if condition="$Think.session.admin.id eq 1">
            <div class="form-group env-class">
                <label class="col-sm-2 control-label">所属角色</label>
                <div class="col-xs-4">
                    <select name="role" class="form-control">
                        <volist name="role" id="vo">
                            <option value="{$vo['id']}">{$vo['name']}</option>
                        </volist>
                    </select>
                </div>
            </div>
            <else/>
            <input type="hidden" name="role" value="2">
        </if>

        <div class="form-group">
            <label class="col-sm-2 control-label">状态</label>
            <div class="col-xs-4">
                <input type="radio" name="status" value="1" checked="checked" />启用
                <input type="radio" name="status" value="0" />禁用
            </div>
        </div>
        <div class="form-actions">
            <div class="col-sm-offset-2">
                <input type="submit" value="提交" name="dosubmit" class="btn btn-primary" >
                <a class="btn btn-default" href="javascript:window.history.go(-1);">返回</a>
            </div>
        </div>
    </form>
</div>

</block>


<block name="script">

    <script type="text/javascript">
        $(document).ready(function() {
            $('#myform').ajaxForm({
                success:  complete,  // post-submit callback
                dataType: 'json'
            });
        });

        function complete(data){
            if (data.status == 1) {
                layer.msg(data.info, {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    window.location.href = "{$Think.cookie.__forward__}";
                    return true;
                });

            } else {
                layer.msg(data.info, {icon: 2});
            }

        }

    </script>
</block>